package br.com.minhasfinancas.api.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;

import br.com.minhasfinancas.fw.model.AbstractModel;


@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "login", name = "UN_USUARIO_LOGIN" ))
public class Usuario extends AbstractModel<Long>{
	private static final long serialVersionUID = 1L;

	@Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
	@Column(name = "ID_USUARIO")
	private Long id;
	
	@NotNull
	@Column(name = "NOME", length = 25)
	private String nome;
	
	@NotNull
	@Column(name = "EMAIL", length = 45)
	private String email;
	
	@NotNull
	@Column(name = "LOGIN", length = 25)
	private String login;
	
	@NotNull
	@Column(name = "SENHA")
	private String senha;
	
	@OneToMany(mappedBy="usuario", fetch = FetchType.LAZY)
	private List<Conta> contas;
	
	
	public Usuario(){
		
	}
	
	
	@Override
	public Long getId() {
		return this.id;
	}
	@Override
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getSenha() {
		return senha;
	}
	public void setSenha(String senha) {
		this.senha = senha;
	}

	public List<Conta> getContas() {
		return contas;
	}

	public void setContas(List<Conta> contas) {
		this.contas = contas;
	}
	
	
}
